<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/jquery-3.6.0.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        h3 {
            padding: 20px 10px;
        }

        li {
            list-style: none;
        }

        .list li {
            line-height: 45px;
            text-indent: 10px;
            border: 1px solid #333;
        }

        .buttonGroup {
            margin-top: 20px;
        }

        .active {
            background-color: #6ff;
        }

        .buttonGroups {
            padding: 10px;
        }
    </style>
</head>

<body>
    <div id="demo" class="wrap">
        <div class="buttonGroups">
            <button>
                css()
            </button>
        </div>
        <div class="list">
            <li class="first">01</li>
            <li>02</li>
            <li class="mid">03</li>
            <li class="four">04</li>
            <li>05</li>
            <li class="last"><span class="demo">06</span></li>
        </div>
    </div>
</body>
<script>
    $("button").eq(0).click(function () {
        // $(".list li").css({ background: "red" });

        // $(".list li").each(function () {
        //     var val = randColor();
        //     $(this).css({ background: val })
        // })

        $(".list li").css({
            background: randColor,
            width: randNum,
            height: randNum,
        });

    })

    function randNum() {
        return Math.round(Math.random() * 200);
    }
    function randColor() {
        var colorStr = "#";
        for (var i = 0; i < 6; i++) {
            var num = Math.round(Math.random() * 16);
            var char = num.toString(16);
            colorStr += char;
        }
        return colorStr;
    }
</script>

</html>